package com.controller.sys;


import com.common.Result;
import com.entity.sys.SysLog;
import com.service.sys.SysLogService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author clay
 * @since 2022-02-15
 */
@RestController
@RequestMapping("/sys/log")
public class SysLogController {


    @Resource
    private SysLogService logService;

    @PostMapping(value = "/select")
    public Result selectSysLog(@RequestBody SysLog sysLog) {
        if (sysLog.getOperationType() == null) {
            return Result.success(logService.queryAll(sysLog));
        } else {
            return Result.success(logService.queryByParam(sysLog));
        }

    }

    @ApiOperation("删除日志")
    @GetMapping("/delete/{id}")
    public Result delete(@PathVariable String id) {
        if (logService.removeById(id)) {
            return Result.success("删除成功");
        }
        return Result.fail("删除失败");
    }

}
